var checkLogin = function(req, res, next) {
    if (!req.session.user) {
      req.flash('error', 'Please sign in firstly!'); 
      res.redirect('/sign-in');
    }
    next();
  };

var checkNotLogin = function(req, res, next) {
    if (req.session.user) {
      req.flash('error', 'You are already sign in!'); 
      res.redirect('back');
    }
    next();
  };

 exports.checkLogin = checkLogin;
 exports.checkNotLogin = checkNotLogin;